//
//  LLMallCell.m
//  LoveLove
//
//  Created by 肖兰月 on 2019/4/4.
//  Copyright © 2019 wkf. All rights reserved.
//

#import "LLMallCell.h"
#import "LLShopGoodsModel.h"

#define leftMargin 10

@interface LLMallCell ()
@property (strong, nonatomic) UIImageView *imgView;
@property (strong, nonatomic) UILabel *titleLbl;
@property (strong, nonatomic) UILabel *priceLbl;
@property (strong, nonatomic) LLButton *doBtn;
@end

@implementation LLMallCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initSubViews];
    }
    return self;
}

- (void)initSubViews {
    CGFloat cellH = LLScreenWidth < 375 ? 100 : 130;
    _imgView = [UIImageView new];
    _imgView.frame = CGRectMake(leftMargin, 10, cellH-20, cellH-20);
    _imgView.layer.cornerRadius = 3;
    _imgView.contentMode = UIViewContentModeScaleAspectFill;
    _imgView.clipsToBounds = YES;
    _imgView.backgroundColor = UIColor.darkGrayColor;
    [self.contentView addSubview:_imgView];
    
    _titleLbl = [LLInitBaseViewTool labelWithText:nil textColor:LLColorRGB(0) font:16 textAlignment:NSTextAlignmentLeft];
    _titleLbl.frame = CGRectMake(_imgView.right + leftMargin, _imgView.top, LLScreenWidth-leftMargin*2-_imgView.right, 50);
    _titleLbl.numberOfLines = 2;
    [self.contentView addSubview:_titleLbl];
    
    _doBtn = [LLInitBaseViewTool buttonWithTitle:nil image:nil titleColor:UIColor.whiteColor font:14];
    _doBtn.layer.cornerRadius = 5;
    _doBtn.backgroundColor = UIColor.redColor;
    _doBtn.frame = CGRectMake(LLScreenWidth-leftMargin-70, _imgView.bottom-30, 70, 30);
    //    [_gatherBtn addTarget:self action:@selector(editBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:_doBtn];
    
    _priceLbl = [LLInitBaseViewTool labelWithText:nil textColor:nil font:0 textAlignment:NSTextAlignmentLeft];
    _priceLbl.frame = CGRectMake(_titleLbl.left, _imgView.bottom-30, _doBtn.left-_titleLbl.left-5, 30);
    [self.contentView addSubview:_priceLbl];
}

- (void)setModel:(LLShopGoodsModel *)model {
    _model = model;
    [_imgView sd_setImageWithURL:LLImageWithUrl(model.goods_pic) placeholderImage:[UIImage imageNamed:@""] options:SDWebImageRefreshCached];
    _titleLbl.text = model.goods_name;
    _priceLbl.attributedText = model.attrPrice;
    [_doBtn setTitle:model.goods_classify_name forState:0];
}

@end
